package com.defeng.common.handler;

import com.defeng.common.utils.R;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 谢德丰
 */
@RestControllerAdvice
@Log4j2
public class ServerExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public R runtimeExceptionHandler(Exception exception){
        log.info("触发异常:[{}]",exception.getMessage());
        exception.printStackTrace();
        return R.error(exception.getMessage());
    }
}
